/**
 * @param {string} s
 * @return {boolean}
 */
var isPalindrome = function(s) {
  function isNumberOrLetter(char) {
    if((char >= 'a' && char <= 'z') || (char >= '0' && char <= '9')) {
      return true;
    } else {
      return false;
    }
  }
  s = s.toLocaleLowerCase();
  let str = [];
  for(let i = 0; i < s.length; i++) {
    if(isNumberOrLetter(s[i]))
      str.push(s[i]);
  }
  if(str.join("") == str.reverse().join(""))
    return true;
  return false;
};
let s = "A man, a plan, a canal: Panama";
console.log(isPalindrome(s));
s = "race a car";
console.log(isPalindrome(s));
